Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/gorilla/mux: allow custom resource naming #617

Merged
merged 1 commit into from
Mar 24, 2020
Merged

contrib/gorilla/mux: allow custom resource naming #617

merged 1 commit into from
Mar 24, 2020

Conversation

tanordheim
Copy link
Contributor

@tanordheim tanordheim commented Mar 23, 2020

Allows customizing the resource names reported to DataDog by specifying a WithResourceNamer option on the Mux router. The namer function takes in the *mux.Router itself and the *http.Request being handled and should provide enough context to produce a resource name for most use cases.

The default namer is still the one that uses the path template on the matched route.

Closes #618

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your first contribution. Would you mind please following our contribution guidelines and opening an issue to discuss the change you want to make before committing to it? It will allow us to more intimately discuss the motivations and find the best possible solution.

Please make sure you explain why you want the change and how it would benefit you.

@tanordheim
Copy link
Contributor Author

Hi - sorry, I missed that part of the guidelines. I've opened an issue now (#618) and linked to it from the PR comment.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial thoughts.

contrib/gorilla/mux/mux.go Outdated Show resolved Hide resolved
contrib/gorilla/mux/mux.go Outdated Show resolved Hide resolved
contrib/gorilla/mux/mux.go Outdated Show resolved Hide resolved
contrib/gorilla/mux/mux_test.go Outdated Show resolved Hide resolved
Adds a new `WithResourceNamer` option for the Gorilla Mux router that
allows customizing how resources are named based on information from the
router itself and the HTTP request being named.
@tanordheim
Copy link
Contributor Author

I've done some tweaks in regards to the changes you requested - let me know if you have more input and I'll happily adjust.

@gbbr gbbr added this to the 1.23.0 milestone Mar 24, 2020
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thanks for your patience! 👏

@tanordheim
Copy link
Contributor Author

Thanks - happy to help!

@gbbr gbbr merged commit 3870aa7 into DataDog:v1 Mar 24, 2020
mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
Adds a new `WithResourceNamer` that allows customizing how resources are named based on information from the router and the request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

contrib/gorilla/mux: tracing option to support setting the resource name
2 participants